package com.example.skillcinema.db.localdb.daos

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.skillcinema.db.localdb.tables.HistoryEntity

@Dao
interface HistoryDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertHistory(history: HistoryEntity)

    @Query("SELECT * FROM history ORDER BY view_date DESC")
    suspend fun getAllHistory(): List<HistoryEntity>

    @Query("SELECT * FROM history WHERE element_id = :elementId")
    suspend fun getHistoryByElementId(elementId: Int): List<HistoryEntity>

    @Query("DELETE FROM history")
    suspend fun clearHistory()
}